using Core;
using UnityEngine;

namespace g_gongjianta
{
    public class WallMainComponent : UnitComponent<Wall>
    {
        private VisualComponent visual;

        public override void Awake()
        {
            base.Awake();

            visual = Unit.Get<VisualComponent>();
            visual.AddLoadListener(OnLoadCompleteHandler);
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            base.Dispose();
        }

        private void OnLoadCompleteHandler()
        {
            visual.RemoveLoadListener(OnLoadCompleteHandler);

            var render = visual.Render;
            render.drawMode = SpriteDrawMode.Tiled;
            var size = render.size;
            size.y = Unit.Conf1.Height;
            render.size = size;
        }
    }
}